home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / graphics / vbcards / cards.bas < prev    next >
Encoding:
BASIC Source File  |  1994-02-21  |  9.5 KB  |  288 lines

  1. Option Explicit
  2.  
  3. ' Using CARDS.DLL with Visual Basic
  4. ' Conversion by Ric Perrott Feb 1994
  5.  
  6. ' This App demonstrates the BASICS of using CARDS.DLL in VB
  7. ' This is by NO MEANS a finished, polished product and as
  8. ' such, the author releases this code to the public domain
  9. ' but releases himself from any damage or misuse that may
  10. ' arise from the use of this product.
  11.  
  12. ' CARDS.DLL is Copyright Microsoft Corporation and this
  13. ' program does NOT give you permission to distribute that
  14. ' file with your own applications.
  15.  
  16. 'Structures to use in Sample App
  17.  
  18. Type tagPOINT
  19.     x As Integer
  20.     y As Integer
  21. End Type
  22.  
  23. Type tagCARD
  24.     CardFace As Integer     'Card # 1-52
  25.     FaceType As Integer       'BOOL Faceup True False
  26.     pt As tagPOINT          'Upper Left Hand corner of card
  27. End Type
  28.  
  29. Global Card As tagCARD
  30.  
  31. 'Function Declarations for CARDS.DLL
  32. Declare Function CardInit Lib "CARDS.DLL" Alias "cdtInit" (PointX As Integer, PointY As Integer) As Integer
  33. ' Pointers to Card coordinates, returns TRUE if succesful
  34.  
  35. Declare Function DrawCard Lib "CARDS.DLL" Alias "cdtDraw" (ByVal hDC As Integer, ByVal PointX As Integer, ByVal PointY As Integer, ByVal Card As Integer, ByVal DrawMode As Integer, ByVal BkGrnd As Long) As Integer
  36. 'Parameters:
  37. 'hDC-    HDC of window to draw cards on
  38. 'x,y -   Upper left hand point
  39. 'Card -   Card # (Use CONSTANTS)
  40. 'Mode-  Draw Mode for Card, see Constants
  41. 'BkGrnd-    An RBG Long value of the Background color for the drawn card
  42. 'RETURNS TRUE IF SUCCESSFUL
  43.  
  44. Declare Function DrawCardEX Lib "CARDS.DLL" Alias "cdtDrawExt" (ByVal hDC As Integer, ByVal PointX As Integer, ByVal PointY As Integer, ByVal ExtX As Integer, ByVal ExtY As Integer, ByVal Card As Integer, ByVal DrawMode As Integer, ByVal BkGrnd As Long) As Integer
  45. ' Extended drawing fuction, allows for nonstandard card sizes.
  46. 'Same params as above plus:
  47. 'ExtX, ExtY-    Lower right hand corner of Card, used to stretch or shrink Cards to specific sizes
  48. 'RETURNS TRUE IF SUCCESSFUL
  49.  
  50. Declare Sub EndCard Lib "CARDS.DLL" Alias "cdtTerm" ()
  51. 'Call when you are finshed with the DLL.
  52.  
  53. Global Center As tagPOINT
  54.  
  55. Global Const IDACLUBS = 0
  56. Global Const ID2CLUBS = 4
  57. Global Const ID3CLUBS = 8
  58. Global Const ID4CLUBS = 12
  59. Global Const ID5CLUBS = 16
  60. Global Const ID6CLUBS = 20
  61. Global Const ID7CLUBS = 24
  62. Global Const ID8CLUBS = 28
  63. Global Const ID9CLUBS = 32
  64. Global Const ID10CLUBS = 36
  65. Global Const IDJCLUBS = 40
  66. Global Const IDQCLUBS = 44
  67. Global Const IDKCLUBS = 48
  68.  
  69. Global Const IDADIAMONDS = 1
  70. Global Const ID2DIAMONDS = 5
  71. Global Const ID3DIAMONDS = 9
  72. Global Const ID4DIAMONDS = 13
  73. Global Const ID5DIAMONDS = 17
  74. Global Const ID6DIAMONDS = 21
  75. Global Const ID7DIAMONDS = 25
  76. Global Const ID8DIAMONDS = 29
  77. Global Const ID9DIAMONDS = 33
  78. Global Const ID10DIAMONDS = 37
  79. Global Const IDJDIAMONDS = 41
  80. Global Const IDQDIAMONDS = 45
  81. Global Const IDKDIAMONDS = 49
  82.  
  83. Global Const IDAHEARTS = 2
  84. Global Const ID2HEARTS = 6
  85. Global Const ID3HEARTS = 10
  86. Global Const ID4HEARTS = 14
  87. Global Const ID5HEARTS = 18
  88. Global Const ID6HEARTS = 22
  89. Global Const ID7HEARTS = 26
  90. Global Const ID8HEARTS = 30
  91. Global Const ID9HEARTS = 34
  92. Global Const IDTHEARTS = 38
  93. Global Const IDJHEARTS = 42
  94. Global Const IDQHEARTS = 46
  95. Global Const IDKHEARTS = 50
  96.  
  97. Global Const IDASPADES = 3
  98. Global Const ID2SPADES = 7
  99. Global Const ID3SPADES = 11
  100. Global Const ID4SPADES = 15
  101. Global Const ID5SPADES = 19
  102. Global Const ID6SPADES = 23
  103. Global Const ID7SPADES = 27
  104. Global Const ID8SPADES = 31
  105. Global Const ID9SPADES = 35
  106. Global Const IDTSPADES = 39
  107. Global Const IDJSPADES = 43
  108. Global Const IDQSPADES = 47
  109. Global Const IDKSPADES = 51
  110.  
  111. Global Const IDGHOST = 53
  112.  
  113. ' To see Card backs, you must use FACEDOWN in the call, rather than FACEUP
  114. 'CB_ stands for CARD BACK
  115. Global Const CB_REDBLUEHATCH = 54
  116. Global Const CB_CROSSHATCH = 55
  117. Global Const CB_ROBOT = 56
  118. Global Const CB_ROSES = 57
  119. Global Const CB_GREENIVY = 58
  120. Global Const CB_BLUEIVY = 59
  121. Global Const CB_REDFISH = 60
  122. Global Const CB_REDFISHBLUEBACK = 61
  123. Global Const CB_SEASHELL = 62
  124. Global Const CB_CASTLE = 63
  125. Global Const CB_PALMTREE = 64
  126. Global Const CB_ACESINHAND = 65
  127.  
  128. Global Const IDFACEDOWNFIRST = CB_REDBLUEHATCH
  129. Global Const IDFACEDOWNLAST = CB_ACESINHAND
  130.  
  131. Global Const X_CARD = 54
  132. Global Const O_CARD = 55
  133.  
  134. ' Red non-face card frame
  135. Global Const IDFRAME = 999
  136.  
  137. 'Draw Modes for Cards
  138. Global Const FACEUP = 0
  139. Global Const FACEDOWN = 1
  140. Global Const HILITE = 2
  141. Global Const GHOST = 3
  142. Global Const REMOVE = 4
  143. Global Const INVISIBLEGHOST = 5
  144. Global Const DECKX = 6
  145. Global Const DECKO = 7
  146.  
  147. Sub FillBackBox ()
  148. Form1!lstBacks.AddItem "CB_REDBLUEHATCH"
  149. Form1!lstBacks.ItemData(0) = CB_REDBLUEHATCH
  150. Form1!lstBacks.AddItem "CB_CROSSHATCH "
  151. Form1!lstBacks.ItemData(1) = CB_CROSSHATCH
  152. Form1!lstBacks.AddItem "CB_ROBOT = "
  153. Form1!lstBacks.ItemData(2) = CB_ROBOT
  154. Form1!lstBacks.AddItem "CB_ROSES = "
  155. Form1!lstBacks.ItemData(3) = CB_ROSES
  156. Form1!lstBacks.AddItem "CB_GREENIVY  "
  157. Form1!lstBacks.ItemData(4) = CB_GREENIVY
  158. Form1!lstBacks.AddItem "CB_BLUEIVY "
  159. Form1!lstBacks.ItemData(5) = CB_BLUEIVY
  160. Form1!lstBacks.AddItem "CB_REDFISH "
  161. Form1!lstBacks.ItemData(6) = CB_REDFISH
  162. Form1!lstBacks.AddItem "CB_REDFISHBLUEBACK "
  163. Form1!lstBacks.ItemData(7) = CB_REDFISHBLUEBACK
  164. Form1!lstBacks.AddItem "CB_SEASHELL "
  165. Form1!lstBacks.ItemData(8) = CB_SEASHELL
  166. Form1!lstBacks.AddItem "CB_CASTLE "
  167. Form1!lstBacks.ItemData(9) = CB_CASTLE
  168. Form1!lstBacks.AddItem "CB_PALMTREE "
  169. Form1!lstBacks.ItemData(10) = CB_PALMTREE
  170. Form1!lstBacks.AddItem "CB_ACESINHAND "
  171. Form1!lstBacks.ItemData(11) = CB_ACESINHAND
  172. End Sub
  173.  
  174. Sub FillCardBox ()
  175.  
  176. Form1!lstCards.AddItem "IDACLUBS"
  177. Form1!lstCards.ItemData(0) = IDACLUBS
  178. Form1!lstCards.AddItem "ID2CLUBS"
  179. Form1!lstCards.ItemData(1) = ID2CLUBS
  180. Form1!lstCards.AddItem "ID3CLUBS"
  181. Form1!lstCards.ItemData(2) = ID3CLUBS
  182. Form1!lstCards.AddItem "ID4CLUBS"
  183. Form1!lstCards.ItemData(3) = ID4CLUBS
  184. Form1!lstCards.AddItem "ID5CLUBS"
  185. Form1!lstCards.ItemData(4) = ID5CLUBS
  186. Form1!lstCards.AddItem "ID6CLUBS"
  187. Form1!lstCards.ItemData(5) = ID6CLUBS
  188. Form1!lstCards.AddItem "ID7CLUBS"
  189. Form1!lstCards.ItemData(6) = ID7CLUBS
  190. Form1!lstCards.AddItem "ID8CLUBS"
  191. Form1!lstCards.ItemData(7) = ID8CLUBS
  192. Form1!lstCards.AddItem "ID9CLUBS"
  193. Form1!lstCards.ItemData(8) = ID9CLUBS
  194. Form1!lstCards.AddItem "ID10CLUBS"
  195. Form1!lstCards.ItemData(9) = ID10CLUBS
  196. Form1!lstCards.AddItem "IDJCLUBS"
  197. Form1!lstCards.ItemData(10) = IDJCLUBS
  198. Form1!lstCards.AddItem "IDQCLUBS"
  199. Form1!lstCards.ItemData(11) = IDQCLUBS
  200. Form1!lstCards.AddItem "IDKCLUBS"
  201. Form1!lstCards.ItemData(12) = IDKCLUBS
  202. Form1!lstCards.AddItem "IDADIAMONDS"
  203. Form1!lstCards.ItemData(13) = IDADIAMONDS
  204. Form1!lstCards.AddItem "ID2DIAMONDS"
  205. Form1!lstCards.ItemData(14) = ID2DIAMONDS
  206. Form1!lstCards.AddItem "ID3DIAMONDS"
  207. Form1!lstCards.ItemData(15) = ID3DIAMONDS
  208. Form1!lstCards.AddItem "ID4DIAMONDS"
  209. Form1!lstCards.ItemData(16) = ID4DIAMONDS
  210. Form1!lstCards.AddItem "ID5DIAMONDS"
  211. Form1!lstCards.ItemData(17) = ID5DIAMONDS
  212. Form1!lstCards.AddItem "ID6DIAMONDS"
  213. Form1!lstCards.ItemData(18) = ID6DIAMONDS
  214. Form1!lstCards.AddItem "ID7DIAMONDS"
  215. Form1!lstCards.ItemData(19) = ID7DIAMONDS
  216. Form1!lstCards.AddItem "ID8DIAMONDS"
  217. Form1!lstCards.ItemData(20) = ID8DIAMONDS
  218. Form1!lstCards.AddItem "ID9DIAMONDS"
  219. Form1!lstCards.ItemData(21) = ID9DIAMONDS
  220. Form1!lstCards.AddItem "ID10DIAMONDS"
  221. Form1!lstCards.ItemData(22) = ID10DIAMONDS
  222. Form1!lstCards.AddItem "IDJDIAMONDS"
  223. Form1!lstCards.ItemData(23) = IDJDIAMONDS
  224. Form1!lstCards.AddItem "IDQDIAMONDS"
  225. Form1!lstCards.ItemData(24) = IDQDIAMONDS
  226. Form1!lstCards.AddItem "IDKDIAMONDS"
  227. Form1!lstCards.ItemData(25) = IDKDIAMONDS
  228.  
  229.  
  230. Form1!lstCards.AddItem "IDAHEARTS"
  231. Form1!lstCards.ItemData(26) = IDAHEARTS
  232. Form1!lstCards.AddItem "ID2HEARTS"
  233. Form1!lstCards.ItemData(27) = ID2HEARTS
  234. Form1!lstCards.AddItem "ID3HEARTS"
  235. Form1!lstCards.ItemData(28) = ID3HEARTS
  236. Form1!lstCards.AddItem "ID4HEARTS"
  237. Form1!lstCards.ItemData(29) = ID4HEARTS
  238. Form1!lstCards.AddItem "ID5HEARTS"
  239. Form1!lstCards.ItemData(30) = ID5HEARTS
  240. Form1!lstCards.AddItem "ID6HEARTS"
  241. Form1!lstCards.ItemData(31) = ID6HEARTS
  242. Form1!lstCards.AddItem "ID7HEARTS"
  243. Form1!lstCards.ItemData(32) = ID7HEARTS
  244. Form1!lstCards.AddItem "ID8HEARTS"
  245. Form1!lstCards.ItemData(33) = ID8HEARTS
  246. Form1!lstCards.AddItem "ID9HEARTS"
  247. Form1!lstCards.ItemData(34) = ID9HEARTS
  248. Form1!lstCards.AddItem "IDTHEARTS"
  249. Form1!lstCards.ItemData(35) = IDTHEARTS
  250. Form1!lstCards.AddItem "IDJHEARTS"
  251. Form1!lstCards.ItemData(36) = IDJHEARTS
  252. Form1!lstCards.AddItem "IDQHEARTS"
  253. Form1!lstCards.ItemData(37) = IDQHEARTS
  254. Form1!lstCards.AddItem "IDKHEARTS"
  255. Form1!lstCards.ItemData(38) = IDKHEARTS
  256.  
  257. Form1!lstCards.AddItem "IDASPADES"
  258. Form1!lstCards.ItemData(39) = IDASPADES
  259. Form1!lstCards.AddItem "ID2SPADES"
  260. Form1!lstCards.ItemData(40) = ID2SPADES
  261.  
  262. Form1!lstCards.AddItem "ID3SPADES"
  263. Form1!lstCards.ItemData(41) = ID3SPADES
  264. Form1!lstCards.AddItem "ID4SPADES"
  265. Form1!lstCards.ItemData(42) = ID4SPADES
  266. Form1!lstCards.AddItem "ID5SPADES"
  267. Form1!lstCards.ItemData(43) = ID5SPADES
  268. Form1!lstCards.AddItem "ID6SPADES"
  269. Form1!lstCards.ItemData(44) = ID6SPADES
  270. Form1!lstCards.AddItem "ID7SPADES"
  271. Form1!lstCards.ItemData(45) = ID7SPADES
  272. Form1!lstCards.AddItem "ID8SPADES"
  273. Form1!lstCards.ItemData(46) = ID8SPADES
  274. Form1!lstCards.AddItem "ID9SPADES"
  275. Form1!lstCards.ItemData(47) = ID9SPADES
  276. Form1!lstCards.AddItem "IDTSPADES"
  277.  Form1!lstCards.ItemData(48) = IDTSPADES
  278. Form1!lstCards.AddItem "IDJSPADES"
  279. Form1!lstCards.ItemData(49) = IDJSPADES
  280. Form1!lstCards.AddItem "IDQSPADES"
  281. Form1!lstCards.ItemData(50) = IDQSPADES
  282. Form1!lstCards.AddItem "IDKSPADES"
  283. Form1!lstCards.ItemData(51) = IDKSPADES
  284.  
  285.  
  286. End Sub
  287.  
  288.